package com.hospital.pony.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hospital.R;
import com.hospital.pony.listener.IntersetListner;
import com.hospital.pony.model.ApplyModel;

import java.util.List;

public class PersonApplyDoctorAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private List<ApplyModel> list_result;
	private int posIndex;
	private Context mContext;
	IntersetListner mIntersetListner;
	public PersonApplyDoctorAdapter(Context context, List<ApplyModel> list_result) {
		mContext = context;
		inflater = LayoutInflater.from(context);
		this.list_result = list_result;
	}

	@Override
	public int getCount() {
		return list_result.size();
	}

	@Override
	public Object getItem(int position) {
		return list_result.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_message_personapply, null);
			holder = new ViewHolder();
			holder.teacherName = (TextView) convertView.findViewById(R.id.teacherName);
			holder.teacherAge = (TextView) convertView.findViewById(R.id.teacherAge);

			holder.teacherhuanzhe = (TextView) convertView.findViewById(R.id.teacherhuanzhe);
			holder.mivUserImage = (ImageView) convertView.findViewById(R.id.mivUserImage);
			holder.deleteMsg = (TextView) convertView.findViewById(R.id.deleteMsg);
			holder.UpdateMsg = (TextView) convertView.findViewById(R.id.UpdateMsg);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		try {
			holder.teacherName.setText(list_result.get(position).getApplyUserName().split("-")[0]);
			holder.teacherhuanzhe.setText(list_result.get(position).getApplyUserName().split("-")[1]);
			holder.teacherAge.setText("预约时间：" + list_result.get(position).getApplyTime());

			holder.deleteMsg.setVisibility(View.VISIBLE);
			if(list_result.get(position).getApplyState().equals("1")){
				holder.teacherAge.setText("待处理");
			}else{
				holder.teacherAge.setText("已处理");
			}


		} catch (Exception e) {
			// TODO: handle exception
		}

		return convertView;

	}

	private class ViewHolder {
		private TextView deleteMsg;
		private TextView UpdateMsg;
		private TextView teacherName;
		private TextView teacherAge;
		private TextView teacherhuanzhe;
		private ImageView mivUserImage;
	}

	public void setPos(int pos) {
		posIndex = pos;
	}

}
